import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: sessionStorage.getItem('state') ? JSON.parse(sessionStorage.getItem('state')) : {
    searchHistoryList: []
  },

  mutations: {
    setSearchHistory(state, str) {
      if (state.searchHistoryList.some(v => v === str)) return
      state.searchHistoryList.push(str)
    },
    clearHistory(state){
      state.searchHistoryList=[]
    }
  },
  actions: {},
  modules: {}
})
